<!--
 * @Author: minglic minglic@foxmail.com
 * @Date: 2023-10-14 15:21:33
 * @LastEditors: minglic minglic@foxmail.com
 * @LastEditTime: 2023-10-21 16:21:00
 * @FilePath: \go2023\cmd\web\vue-element-admin\src\views\site\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div style="padding:5px;">

        <el-form ref="form" :model="site" label-width="80px">
            <el-form-item label="泵站名称">
                <el-input v-model="site.name"></el-input>
            </el-form-item>
            <el-form-item label="管理员">
                <el-input v-model="site.manager"></el-input>
            </el-form-item>
            <el-form-item label="地址">
                <el-input v-model="site.address"></el-input>
            </el-form-item>
            <el-form-item label="备注">
                <el-input type="textarea" v-model="site.desc"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">保存</el-button>
                <el-button @click="close">取消</el-button>
            </el-form-item>
        </el-form>

    </div>
</template>

<script>

import {create, update, list, remove} from "@/api/site"

export default {
    props: ["site"],
    data() {
        return {
           
        }
    },
    created(){

    },
    methods: {
        onSubmit(){
            if(this.site.id){
                this.update()
            }else{
                this.create()
            }
        },
        update(){
            update(this.site).then((res)=>{
                this.$message.success("修改成功")
                this.$emit('change')
                this.$emit('close')
            })
        },
        create(){
            create(this.site).then((res)=>{
                this.$message.success("添加成功")
                this.$parent.dialogVisible = false
                this.$emit('change')
                this.$emit('close')
            })
        },
        close(){
            this.$emit("close")
        }
    }
}
</script>